#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>

using std::vector;
using std::cin;
using std::cout;
struct interval {
    int begin;
    int end;
};
void Input(int &n, int &a, int &b, vector<vector<int> > &graf) {
    cin >> n >> a >> b;
    graf.resize(2 * n);
    // 2*i - start 2*i + 1 - finish
    int first, second;
    for (int i = 0; i < n; ++i) {
        graf[i * 2].push_back(i * 2 + 1);
    }
    for (int i = 0; i < a; ++i) {
        cin >> first >> second;
        --first, --second;
        graf[first * 2].push_back(second * 2);
        graf[first * 2].push_back(second * 2 + 1);
        graf[first * 2 + 1].push_back(second * 2);
        graf[first * 2 + 1].push_back(second * 2 + 1);
    }
    for (int i = 0; i < b; ++i) {
        cin >> first >> second;
        --first, --second;
        graf[second * 2].push_back(first * 2 + 1);
        graf[first * 2].push_back(second * 2 + 1);
    }
}

bool dfs(vector<vector<int> > const &graf, vector<int> &buffer, vector<int> &marks, int curr) {
    if (marks[curr] == 1)
        return 0;
    if (marks[curr] == 2)
        return 1;
    marks[curr] = 1;
    for (int i = 0; i < graf[curr].size(); ++i) {
        if(dfs(graf, buffer, marks, graf[curr][i]))
            continue;
        return 0;
    }
    buffer.push_back(curr);
    marks[curr] = 2;
    return 1;
}

bool TopSort(vector<vector<int> > const &graf, vector<int> &buffer) {
    vector<int> marks(graf.size(), 0);
    for (int i = 0; i < graf.size(); ++i) {
        if (!marks[i]) {
            if (dfs(graf, buffer, marks, i)) {
                continue;
            }
            return 0;
        }
    }
    std::reverse(buffer.begin(), buffer.end());
    return 1;
}

void MakeIntervals(vector<int> const &buffer, vector<interval> &intervals) {
    for (int i = 0; i < buffer.size(); ++i) {
        if (buffer[i] % 2) {
            intervals[buffer[i] / 2].end = i;
        }
        else {
            intervals[buffer[i] / 2].begin = i;
        }
    }
}

void Output(vector<interval> const &intervals) {
    for (int i = 0; i < intervals.size(); ++i) {
        cout << intervals[i].begin << ' ' << intervals[i].end << std::endl;
    }
}

int main() {
    int n, a, b;
    vector<vector<int> > graf;
    Input(n, a, b, graf);
    vector<int> buffer;
    if(!TopSort(graf, buffer)) {
        cout << "Impossible";
        return 0;
    }
    vector<interval> intervals(n);
    MakeIntervals(buffer, intervals);
    Output(intervals);
    return 0;
}